Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Adds support for SSH servers requiring keyboard-interactive authentication (2FA/MFA). Previously, connecting to hosts with multi-factor auth would fail silently.

Changes

Frontend

  • New KeyboardInteractiveModal component displays server prompts and collects user responses
  • Integrated at app level to handle prompts from SSH, SFTP, and port forwarding connections
  • Added EN/CN translations for modal UI

Backend

  • keyboardInteractiveHandler.cjs - Shared module for centralized request/response management across all connection types
  • SSH, SFTP, and port forwarding bridges now handle the keyboard-interactive event from ssh2
  • Connection timeout increased to 120s to allow time for 2FA input
  • IPC bridge extended with onKeyboardInteractive and respondKeyboardInteractive methods

Flow

Server → ssh2 keyboard-interactive event → Main process → IPC → Modal prompt
User input → IPC → Main process → ssh2 finish callback → Connection established

Notes

  • Single IPC handler registration in SSH bridge serves all connection types via shared module
  • Supports multiple sequential prompts (some servers ask multiple questions)
  • Password fields masked based on prompt's echo property
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]希望增加一个双因子2FA登录的方式</issue_title>
<issue_description>希望增加一个双因子登录2FA的方式,类似于如下功能:

Image

不然的话有些节点无法登录上去,需要用其他软件替代</issue_description>

<agent_instructions>根据用户的截图,调研一下用户所提到的这个功能实现的可能性,如果可以,尝试实现一下。
注意:如果需要填写多因素认证的code,请考虑全局弹modal让用户填写,因为sftp 跳板机 端口转发功能可能都涉及到多因素认证,如果此功能是通用的,请封装统一的modal来实现。</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add two-factor authentication (2FA) login feature Add keyboard-interactive (2FA/MFA) authentication support Jan 19, 2026
Copilot AI requested a review from binaricat January 19, 2026 18:20
…interactive requests

- Extract createProxySocket to shared proxyUtils.cjs module
- Add 5-minute TTL cleanup for abandoned keyboard-interactive requests
- Update sshBridge.cjs and sftpBridge.cjs to use shared module
The ssh2 library requires tryKeyboard: true in connection options to
trigger the 'keyboard-interactive' event. Without this setting, the
library will not attempt keyboard-interactive authentication even if
it's listed in authHandler.

Added to all connection configurations:
- sshBridge.cjs (main connection + jump hosts)
- sftpBridge.cjs (main connection + jump hosts)
- portForwardingBridge.cjs
When a server uses keyboard-interactive for both password and 2FA:
1. First round prompts for "Password:" - now auto-filled with configured password
2. Second round prompts for 2FA code - shows modal for user input

This fixes the issue where users had to manually enter password in the
2FA modal, leading to authentication failures.

Applied to:
- sshBridge.cjs
- sftpBridge.cjs
- portForwardingBridge.cjs
@binaricat binaricat marked this pull request as ready for review January 20, 2026 02:37
@binaricat binaricat merged commit 918d588 into main Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]希望增加一个双因子2FA登录的方式

2 participants